/*
 * Copyright (c) 2006-2023, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2023-10-25     RT-Thread    first version
 */

#include <rtthread.h>
#include "Bsp/bsp_uart3.h"
#include "App/app_io.h"
#include "HJComm/HJMasterDevice.h"
#include "app/app_comm.h"
#include "bsp/bsp_crc.h"

#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

#define NODE_ID         2
#define SOFT_VERSION    "1.0.0.2"

extern "C" int main(void)
{
    int count = 1;

    bsp_crc_init();
    app_io_init();
    bsp_uart3_init();

    LOG_D("Ver %s", SOFT_VERSION);

    HJDeiviceWrapInit(NODE_ID, (uint8_t*)SOFT_VERSION);

    Recv_thread_init();
    while (count++)
    {
        uint8_t des_id[4] = { 0, 0, 0, 255};
        char json_rep[512] = {0};
        app_rep_process(json_rep, sizeof(json_rep));
        HJDeiviceWrapTxProcess(des_id, (uint8_t*)json_rep, strlen(json_rep));
//        HJDeiviceFrameHandleWrap(NODE_ID, (uint8_t*)SOFT_VERSION);
        rt_thread_mdelay(2000);
    }

    return RT_EOK;
}
